  <template>
  <div>
    <el-input
      placeholder="请输入内容"
      prefix-icon="el-icon-search"
      v-model="input2"
    >
    </el-input>
    <el-table :data="tableData" :row-style="fn" style="width: 100%">
      <el-table-column prop="date" label="日期" width="180"> </el-table-column>
      <el-table-column prop="name" label="姓名" width="180"> </el-table-column>
      <el-table-column prop="address" label="地址"> </el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope)" type="text" size="small"
            >查看</el-button
          >
          <el-button v-show="scope.$index === 1" type="text" size="small"
            >233</el-button
          >
          <el-button type="text" size="small">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  methods: {
    fn(n) {
      console.log("233");
      const styleRes = { background: "#0181C2 !important" };
      if (this.tableData[n.rowIndex].name === this.input2) {
        console.log("111");
        return styleRes;
      }
      console.log(n.rowIndex, "233");
    },
    handleClick(n) {
      console.log(n);
    },
  },
  data() {
    return {
      input2: "",
      tableData: [
        {
          date: "2016-05-02",
          name: "小兰",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "小红",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
        },
        {
          date: "2016-05-03",
          name: "小张",
          address: "上海市普陀区金沙江路 1516 弄",
        },
      ],
    };
  },
};
</script>

<style lang="less" scoped>
</style>
